package com.lz.springcloud.tools.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lz.springcloud.tools.service.RedisService;

@RestController
@RequestMapping("tools/redis")
public class RedisController {
 
    @Autowired
    RedisService redis;
    
    @GetMapping("get")
    public String get(@RequestParam("key") String key) {
    	return redis.get(key);
    }
    
    @GetMapping("add")
    public boolean add(@RequestParam("key") String key,@RequestParam("value") String value) {
    	return redis.set(key , value);
    }
    
    @GetMapping("del")
    public boolean del(@RequestParam("key") String key) {
    	return redis.del(key);
    }
    
    @GetMapping("exp")
    public boolean exp(@RequestParam("key") String key,@RequestParam("time") Long time) {
    	return redis.expire(key,time);
    }
}
